package com.iknight.theory.service.impl;

import com.iknight.mgr.core.constant.EquipConstant;
import com.iknight.mgr.core.utils.IkgStringUtils;
import com.iknight.mgr.mapper.PubCodeMapper;
import com.iknight.theory.api.TeModelLibService;
import com.iknight.theory.api.TheoryCommService;
import com.iknight.theory.mapper.*;
import com.iknight.theory.model.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by jeryzym on 2017/10/18.
 * 理论线损服务实现
 */
@Service
public class TheoryCommonServiceImpl implements TheoryCommService {

    private static final Logger logger = LogManager.getLogger(TheoryCommonServiceImpl.class);
    @Autowired
    private TeModelLibService teModelLibService;
    /**
     * 台区Mapper
     */
    @Autowired
    private TeTgMapper<TETgModel, String> teTgMapper;
    /**
     * 配变Mapper
     */
    @Autowired
    private TeTranMapper<TETranModel, String> teTranMapper;
    @Autowired
    private TeConsMapper<TEConsModel, String> teConsMapper;
    @Autowired
    private TeLineMapper<TELineModel, String> teLineMapper;
    @Autowired
    private TeLineSegMapper<TELineSegModel, String> teLineSegMapper;
    @Autowired
    private TeLinePoleMapper<TELinePoleModel, String> teLinePoleMapper;
    @Autowired
    private TeLineConsMapper<TELineConsModel, String> teLineConsMapper;
    @Autowired
    private TeContainerMapper<TEContainerModel, String> teContainerMapper;
    @Autowired
    private TeRecordMapper<TPRecordModel, String> teRecordMapper;
    @Autowired
    private TPCurrentMapper<TPCurrentModel, String> tpCurrentMapper;
    @Autowired
    private PubCodeMapper pubCodeMapper;


    @Transactional
    @Override
    public Object analyzeParsedExcel(List<JSONObject> list) {


        String tg_id = IkgStringUtils.getUUID();//台区标识
        String tran_id = IkgStringUtils.getUUID();//变压器标识
        String line_id = IkgStringUtils.getUUID();//线路标识
        Map positions = new HashMap();//用于存储位置
        Map segments = new HashMap();//用于存储线段
        Map containers = new HashMap();//用于存储计量箱

//        DecimalFormat df = new DecimalFormat("#.00");//小数点后面保留两位
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String date = null;

        TETgModel tg = new TETgModel();
        TETranModel tran = new TETranModel();
        TELineModel line = new TELineModel();
        List<TELineSegModel> lineSegModelList = new ArrayList<>();
        List<TELineConsModel> lineConsModelList = new ArrayList<>();
        List<TEConsModel> consModelList = new ArrayList<>();
        List<TPRecordModel> tpRecordModelList = new ArrayList<>();
        List<TEContainerModel> containerModelList = new ArrayList<>();
        List<TELinePoleModel> poleModelList = new ArrayList<>();
        List<TPCurrentModel> currentModels = new ArrayList<>();

        if (null == list) {
            JSONObject result = new JSONObject();
            result.put("message","读取sheet失败，导入失败!");
            return result;
        }

        for (int k = 0; k < list.size(); k++) {
            JSONObject jo = list.get(k);

            String tableName = jo.getString("tableName");
            List<JSONObject> dataSet = (List<JSONObject>) jo.get("data");

            for (JSONObject temp : dataSet) {//遍历数据集合
                logger.info("tableName:" + tableName);
                tableName = tableName.toUpperCase();
                if (tableName.equals("T_EQUIP_TG")) {
                    tg.setTg_id(tg_id);
                    tg.setIs_effective("1");
                    tg = (TETgModel) analyzeParsedTGInfo(tg, temp);
                    logger.info(tg.toString());
                } else if (tableName.equals("T_EQUIP_TRAN")) {
                    tran.setTran_id(tran_id);
                    tran.setTg_id(tg_id);
                    tran.setIs_effective("1");
                    tran.setRecord_date(sdf.format(Calendar.getInstance().getTime()));

                    Map result = (Map) analyzeParsedTranInfo(tran, temp);
                    date = result.get("recordDate").toString();
                    tran = (TETranModel) result.get("tran");
                    List<TPRecordModel> powers = (List) result.get("power");
                    for (TPRecordModel power : powers) {
                        tpRecordModelList.add(power);
                    }
                    logger.info(tran.toString());
                } else if (tableName.equals("T_EQUIP_LINE")) {
                    line.setLine_id(line_id);
                    line.setTg_id(tg_id);
                    line.setTran_id(tran_id);
                    line = (TELineModel) analyzeParsedLineInfo(line, temp);
                } else if (tableName.equals("T_EQUIP_LINE_SEG")) {
                    Map result = (Map) analyzeParsedLineSegInfo(line_id, positions, segments, temp);
                    TELineSegModel model = (TELineSegModel) result.get("segment");
                    positions = (Map) result.get("positionMap");
                    segments = (Map) result.get("segmentMap");

                    lineSegModelList.add(model);
                } else if (tableName.equals("T_EQUIP_LINE_CONS")) {

                    Map result = (Map) analyzeParsedLineConsInfo(line_id, positions, containers, temp);
                    containers = (Map) result.get("containerMap");
                    TELineConsModel model = (TELineConsModel) result.get("lineCons");

                    lineConsModelList.add(model);
                } else if (tableName.equals("T_EQUIP_CONS")) {
                    Map result = (Map) analyzeParsedConsInfo(tg_id, date, containers, temp);
                    TEConsModel cons = (TEConsModel) result.get("cons");
                    TPRecordModel power = (TPRecordModel) result.get("power");
                    consModelList.add(cons);
                    tpRecordModelList.add(power);
                } else if (tableName.equals("T_RECORD_CURRENT")) {
                    Map result = (Map) analyzeParsedCurrentInfo(tran_id, temp);
                    currentModels.add((TPCurrentModel) result.get("current"));
                }
            }
        }
        if (!containers.isEmpty()) {
            Set set = containers.keySet();
            Iterator ito = set.iterator();

            while (ito.hasNext()) {
                TEContainerModel model = new TEContainerModel();
                String key = String.valueOf(ito.next());
                String value = String.valueOf(containers.get(key));
                model.setContainer_id(value);
                model.setAsset_no(key);
                model.setIs_effective("1");
                model.setLine_id(line_id);
                model.setTg_id(tg_id);
                containerModelList.add(model);
            }
        }
        if (!positions.isEmpty()) {
            Set set = positions.keySet();
            Iterator ito = set.iterator();
            while (ito.hasNext()) {
                TELinePoleModel model = new TELinePoleModel();
                String key = String.valueOf(ito.next());
                String value = String.valueOf(positions.get(key));
                model.setPole_id(value);
                model.setPole_no(key);
                model.setIs_effective("1");
                model.setLine_id(line_id);
                poleModelList.add(model);
            }
        }
        //修正日期
        List<TPRecordModel> fixedRecordLs = new ArrayList<>();
        for (TPRecordModel power : tpRecordModelList) {
            power.setData_date(date);
            fixedRecordLs.add(power);
        }
        tran.setSection_date(date);
        //修正台区标识，一个台区多个断面
        Map param = new HashMap();
        param.put("tg_no", tg.getTg_no());
        List<TETgModel> existedTgs = teTgMapper.selectByCond(param);
        if (null != existedTgs && existedTgs.size() > 0) {
            TETgModel existedTg = existedTgs.get(0);
            String existedTgId = existedTg.getTg_id();
            //开始修正
            tg.setTg_id(existedTgId);
            tran.setTg_id(existedTgId);
            line.setTg_id(existedTgId);
            for (int i = 0; i < consModelList.size(); i++) {
                consModelList.get(i).setTg_id(existedTgId);
            }
            for (int i = 0; i < containerModelList.size(); i++) {
                containerModelList.get(i).setTg_id(existedTgId);
            }
            teTgMapper.update(tg);
        } else {
            teTgMapper.insert(tg);
        }
        teTranMapper.insert(tran);
        teLineMapper.insert(line);
        //执行数据插入
        for (TEContainerModel model : containerModelList) {
            if (IkgStringUtils.isNotNull(model.getContainer_id())) {
                teContainerMapper.insert(model);
            }
        }
        for (TELineSegModel model : lineSegModelList) {
            if (IkgStringUtils.isNotNull(model.getSeg_id())) {
                teLineSegMapper.insert(model);
            }
        }
        for (TEConsModel model : consModelList) {
            if (IkgStringUtils.isNotNull(model.getCons_id())) {
                teConsMapper.insert(model);
            }
        }
        for (TELinePoleModel model : poleModelList) {
            if (IkgStringUtils.isNotNull(model.getPole_id())) {
                teLinePoleMapper.insert(model);
            }
        }
        for (TELineConsModel model : lineConsModelList) {
            if (IkgStringUtils.isNotNull(model.getCl_id())) {
                teLineConsMapper.insert(model);
            }
        }
        for (TPRecordModel model : fixedRecordLs) {
            if (IkgStringUtils.isNotNull(model.getObj_id())) {
                teRecordMapper.insert(model);
            }
        }
        for (TPCurrentModel model : currentModels) {
            if (IkgStringUtils.isNotNull(model.getObj_id())) {
                tpCurrentMapper.insert(model);
            }
        }
        JSONObject result = new JSONObject();
        result.put("message", "完成数据入库明细如下[线路分段:"
                + lineSegModelList.size() + "条,低压杆塔:"
                + poleModelList.size() + "条,低压用户数:"
                + consModelList.size() + "条,进户线:"
                + lineConsModelList.size() + "条,电量数据:"
                + fixedRecordLs.size() + "条，电流数据："
                + currentModels.size() + "条");

        return result;
    }

    @Override
    public Object analyzeParsedTGInfo(TETgModel model, JSONObject dataSet) {
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据
        for (int i = 0; i < ja.size(); i++) {//逐行解析数据
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();
            while (keys.hasNext()) {//遍历记录集
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));
                if (key.equals("tg_no")) {
                    model.setTg_no(value);
                } else if (key.equals("tg_name")) {
                    model.setTg_name(value);
                } else if (key.equals("tg_capacity")) {
                    model.setTg_capacity(Double.valueOf(value.equals("") ? "0" : value));
                }
            }
        }
        return model;
    }

    @Override
    public Object analyzeParsedTranInfo(TETranModel model, JSONObject dataSet) {
        Map result = new HashMap();
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String record_date = sdf.format(Calendar.getInstance().getTime());

        List<TPRecordModel> recordModels = new ArrayList<>();

        for (int i = 0; i < ja.size(); i++) {//逐行解析数据,只解析第一行
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();
            while (keys.hasNext()) {//遍历记录集
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));
                if (key.equals("power_date")) {//数据日期
                    if (value.length() != 0) {
                        record_date = value;
                    } else {
                        logger.warn("检测到数据日期为空，系统将调整到默认当前日期:[" + record_date + "]");
                        result.put("parseWarn", "检测到数据日期为空，系统将调整到默认当前日期:[" + record_date + "]");
                    }
                }

                if (key.equals("tran_no")) {
                    model.setTran_no(value);
                } else if (key.equals("tran_name")) {
                    model.setTran_name(value);
                } else if (key.equals("tran_capacity")) {//变压器容量
                    model.setTran_capacity(Double.valueOf(value.equals("") ? "0" : value));
                } else if (key.equals("tran_model")) {//变压器型号
                    TEModelLibModel lib = (TEModelLibModel) teModelLibService.getModelLibByNameAndType(value, EquipConstant.LIB_TYPE_TRAN);
                    model.setTran_model(null == lib ? "" : lib.getModel_id());
                } else if (key.equals("power_yg")) {//有功电量
                    TPRecordModel power = new TPRecordModel();
                    power.setObj_id(IkgStringUtils.getUUID());
                    power.setEquip_id(model.getTran_id());
                    power.setEquip_type(EquipConstant.POWER_TYPE_TRAN);
                    power.setData_date(record_date);//数据日期
                    power.setData_type(EquipConstant.POWER_TYPE_ZXYG);//正向有功电量
                    power.setData_value(Double.valueOf(value.equals("") ? "0" : value));

                    recordModels.add(power);
                } else if (key.equals("power_wg")) {//无功电量
                    TPRecordModel power = new TPRecordModel();

                    power.setObj_id(IkgStringUtils.getUUID());
                    power.setEquip_id(model.getTran_id());
                    power.setEquip_type(EquipConstant.POWER_TYPE_TRAN);
                    power.setData_type(EquipConstant.POWER_TYPE_ZXWG);
                    power.setData_date(record_date);
                    power.setData_value(Double.valueOf(value.equals("") ? "0" : value));

                    recordModels.add(power);
                } else if (key.equals("power_glys")) {//功率因数
                    TPRecordModel power = new TPRecordModel();

                    power.setObj_id(IkgStringUtils.getUUID());
                    power.setEquip_id(model.getTran_id());
                    power.setEquip_type(EquipConstant.POWER_TYPE_TRAN);
                    power.setData_type(EquipConstant.POWER_TYPE_GLYS);
                    power.setData_date(record_date);
                    power.setData_value(Double.valueOf(value.equals("") ? "0" : value));

                    recordModels.add(power);
                }
            }
        }
        result.put("tran", model);
        result.put("recordDate", record_date);
        result.put("power", recordModels);
        return result;
    }

    @Override
    public Object analyzeParsedLineInfo(TELineModel model, JSONObject dataSet) {
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据
        for (int i = 0; i < ja.size(); i++) {//遍历行数据
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();
            while (keys.hasNext()) {
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));
                if (key.equals("line_no")) {
                    model.setLine_no(value);
                } else if (key.equals("line_name")) {
                    model.setLine_name(value);
                }
            }
        }
        return model;
    }

    @Override
    public Object analyzeParsedLineSegInfo(String line_id, Map<String, String> positions, Map<String, String> segments, JSONObject dataSet) {
        Map result = new HashMap();

        JSONArray ja = dataSet.getJSONArray("row");//获得行数据
        TELineSegModel model = new TELineSegModel();
        String lineSeg_id = IkgStringUtils.getUUID();
        model.setSeg_id(lineSeg_id);
        model.setLine_id(line_id);
        model.setIs_effective("1");

        for (int i = 0; i < ja.size(); i++) {//遍历行数据
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();

            while (keys.hasNext()) {
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));
                if (key.equals("seg_no")) {
                    model.setSeg_no(value);
                    if (!segments.containsKey(value)) {
                        segments.put(value, lineSeg_id);
                    }

                } else if (key.equals("start_pos_no")) {
                    String id = IkgStringUtils.getUUID();
                    //遍历
                    if (!positions.containsKey(value)) {
                        positions.put(value, id);
                        model.setStart_pos(id);
                    } else {
                        model.setStart_pos(IkgStringUtils.ObjectToString(positions.get(value)));
                    }
                } else if (key.equals("start_type")) {
                    if (value.equals(EquipConstant.TYPE_TRAN_NAME)) {
                        model.setStart_type(EquipConstant.TYPE_TRAN);
                    } else if (value.equals(EquipConstant.TYPE_POLE_NAME)) {
                        model.setStart_type(EquipConstant.TYPE_POLE);
                    }
                } else if (key.equals("end_pos_no")) {
                    String endPos = IkgStringUtils.getUUID();
                    if (!positions.containsKey(value)) {
                        positions.put(value, endPos);
                        model.setEnd_pos(endPos);
                    } else {
                        model.setEnd_pos(IkgStringUtils.ObjectToString(positions.get(value)));
                    }
                } else if (key.equals("end_type")) {
                    if (value.equals(EquipConstant.TYPE_TRAN_NAME)) {
                        model.setEnd_type(EquipConstant.TYPE_TRAN);
                    } else if (value.equals(EquipConstant.TYPE_POLE_NAME)) {
                        model.setEnd_type(EquipConstant.TYPE_POLE);
                    }
                } else if (key.equals("line_length")) {
                    model.setSeg_length(Double.valueOf(value));
                } else if (key.equals("line_model")) {
                    TEModelLibModel lib = (TEModelLibModel) teModelLibService.getModelLibByNameAndType(value, EquipConstant.LIB_TYPE_SEG);
                    model.setSeg_model(null == lib ? "" : lib.getModel_id());
                }
            }
        }

        result.put("segment", model);
        result.put("positionMap", positions);
        result.put("segmentMap", segments);

        return result;
    }

    @Override
    public Object analyzeParsedLineConsInfo(String line_id, Map positions, Map containers, JSONObject dataSet) {
        Map result = new HashMap();
        TELineConsModel model = new TELineConsModel();
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据
        String lineCons_id = IkgStringUtils.getUUID();
        model.setCl_id(lineCons_id);
        model.setIs_effective("1");
        model.setLine_id(line_id);

        for (int i = 0; i < ja.size(); i++) {//遍历行数据
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();

            while (keys.hasNext()) {
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));

                if (key.equals("jhx_no")) {//进户线编号
                    model.setCl_no(value);
                } else if (key.equals("pole_no")) {//挂接杆塔
                    model.setStart_pos(IkgStringUtils.ObjectToString(positions.get(value)));
                } else if (key.equals("jhx_length")) {
                    model.setCl_length(Double.valueOf(value));
                } else if (key.equals("jhx_model")) {
                    TEModelLibModel lib = (TEModelLibModel) teModelLibService.getModelLibByNameAndType(value, EquipConstant.LIB_TYPE_LINECONS);
                    model.setCl_model(lib == null ? "" : lib.getModel_id());
                } else if (key.equals("container_no")) {
                    String container_id = IkgStringUtils.getUUID();

                    if (!containers.containsKey(value)) {
                        containers.put(value, container_id);
                        model.setContainer_id(container_id);
                    } else {
                        model.setContainer_id(IkgStringUtils.ObjectToString(containers.get(value)));
                    }
                }
            }
        }
        result.put("lineCons", model);
        result.put("containerMap", containers);
        return result;
    }

    @Override
    public Object analyzeParsedConsInfo(String tg_id, String recordDate, Map containers, JSONObject dataSet) {
        Map result = new HashMap();
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据

        TPRecordModel power = new TPRecordModel();
        TEConsModel model = new TEConsModel();

        String cons_id = IkgStringUtils.getUUID();
        model.setCons_id(cons_id);
        model.setTg_id(tg_id);
        model.setIs_effective("1");

        for (int i = 0; i < ja.size(); i++) {//遍历行数据
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();

            while (keys.hasNext()) {
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));

                if (key.equals("cons_no")) {
                    model.setCons_no(value);
                } else if (key.equals("cons_name")) {
                    model.setCons_name(value);
                } else if (key.equals("meter_asset_no")) {
                    model.setMeter_asset_no(value);
                } else if (key.equals("meter_model")) {
                    TEModelLibModel lib = (TEModelLibModel) teModelLibService.getModelLibByNameAndType(value, EquipConstant.LIB_TYPE_METER);
                    model.setMeter_model(null == lib ? "" : lib.getModel_id());
                } else if (key.equals("conntainer_no")) {
                    model.setContainer_id(containers.get(value) == null ? "" : IkgStringUtils.ObjectToString(containers.get(value)));
                } else if (key.equals("cons_power")) {
                    power.setObj_id(IkgStringUtils.getUUID());
                    power.setEquip_id(cons_id);
                    power.setEquip_type(EquipConstant.POWER_TYPE_CONS);
                    power.setData_type(EquipConstant.POWER_TYPE_ZXYG);
                    power.setData_date(recordDate);
                    power.setData_value(Double.valueOf(value.equals("") ? "0" : value));
                }
            }
        }
        result.put("power", power);
        result.put("cons", model);
        return result;
    }

    @Override
    public Object analyzeParsedCurrentInfo(String tran_id, JSONObject dataSet) {
        Map result = new HashMap();
        JSONArray ja = dataSet.getJSONArray("row");//获得行数据
        TPCurrentModel model = new TPCurrentModel();
        model.setObj_id(IkgStringUtils.getUUID());
        model.setTran_id(tran_id);
        for (int i = 0; i < ja.size(); i++) {
            JSONObject tempJO = ja.getJSONObject(i);
            Set set = tempJO.keySet();
            Iterator<String> keys = set.iterator();

            while (keys.hasNext()) {//遍历记录集
                String key = keys.next().toLowerCase();
                String value = IkgStringUtils.ObjectToString(tempJO.get(key));
                if (key.equals("phase")) {
                    List<Map> phaseTypes = pubCodeMapper.getOptionsByPCode("phase_type");
                    for (Map map : phaseTypes) {
                        if (value.equals(map.get("code_text"))) {
                            model.setPhase_type(IkgStringUtils.ObjectToString(map.get("code_value")));
                        }
                    }
                } else if (key.equals("value0")) {
                    model.setValue_0(Double.valueOf(value));
                } else if (key.equals("value1")) {
                    model.setValue_1(Double.valueOf(value));
                } else if (key.equals("value2")) {
                    model.setValue_2(Double.valueOf(value));
                } else if (key.equals("value3")) {
                    model.setValue_3(Double.valueOf(value));
                } else if (key.equals("value4")) {
                    model.setValue_4(Double.valueOf(value));
                } else if (key.equals("value5")) {
                    model.setValue_5(Double.valueOf(value));
                } else if (key.equals("value6")) {
                    model.setValue_6(Double.valueOf(value));
                } else if (key.equals("value7")) {
                    model.setValue_7(Double.valueOf(value));
                } else if (key.equals("value8")) {
                    model.setValue_8(Double.valueOf(value));
                } else if (key.equals("value9")) {
                    model.setValue_9(Double.valueOf(value));
                } else if (key.equals("value10")) {
                    model.setValue_10(Double.valueOf(value));
                } else if (key.equals("value11")) {
                    model.setValue_11(Double.valueOf(value));
                } else if (key.equals("value12")) {
                    model.setValue_12(Double.valueOf(value));
                } else if (key.equals("value13")) {
                    model.setValue_13(Double.valueOf(value));
                } else if (key.equals("value14")) {
                    model.setValue_14(Double.valueOf(value));
                } else if (key.equals("value15")) {
                    model.setValue_15(Double.valueOf(value));
                } else if (key.equals("value16")) {
                    model.setValue_16(Double.valueOf(value));
                } else if (key.equals("value17")) {
                    model.setValue_17(Double.valueOf(value));
                } else if (key.equals("value18")) {
                    model.setValue_18(Double.valueOf(value));
                } else if (key.equals("value19")) {
                    model.setValue_19(Double.valueOf(value));
                } else if (key.equals("value20")) {
                    model.setValue_20(Double.valueOf(value));
                } else if (key.equals("value21")) {
                    model.setValue_21(Double.valueOf(value));
                } else if (key.equals("value22")) {
                    model.setValue_22(Double.valueOf(value));
                } else if (key.equals("value23")) {
                    model.setValue_23(Double.valueOf(value));
                }
            }
        }

        result.put("current", model);
        return result;
    }
}
